﻿<Window x:Class="WPFLoaders.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpfLoaders="clr-namespace:WPFLoaders"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" SizeToContent="WidthAndHeight"
        Width="540"
        Icon="Icon.ico">
    <Window.Resources>
        <ContextMenu x:Key="SaveMenu">
            <MenuItem Header="Save" Click="OnSave" />
        </ContextMenu>
        <Style TargetType="HeaderedContentControl" x:Key="LoaderDisplay">
            <Setter Property="Margin" Value="10"/>
            <Setter Property="ContextMenu" Value="{StaticResource SaveMenu}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="HeaderedContentControl">
                        <Border Name="MainBackground" Background="DarkSlateGray" Padding="10" CornerRadius="7">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Border Background="White" BorderBrush="DimGray" BorderThickness="1" Padding="5">
                                    <ContentPresenter Grid.Row="0" Height="125" Width="125" />
                                </Border>
                                <TextBlock Grid.Row="1" Text="{TemplateBinding Header}" HorizontalAlignment="Center" Margin="0,8,0,0" Foreground="AntiqueWhite"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="MainBackground" Property="Background" Value="LightSlateGray"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>
    <WrapPanel>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="RainbowStar">
            <ContentPresenter ContentTemplate="{StaticResource RainbowStarLoader}"/>
        </HeaderedContentControl>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="Dots">
            <Viewbox Stretch="Uniform" Width="125" Height="125">
                <ItemsControl>
                    <ItemsControl.ItemsSource>
                        <wpfLoaders:ItemsGenerator Items="5" />
                    </ItemsControl.ItemsSource>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Ellipse Width="10" Height="10" Fill="Black" Margin="5" Opacity="0">
                                <Ellipse.RenderTransform>
                                    <TranslateTransform/>
                                </Ellipse.RenderTransform>
                                <Ellipse.Triggers>
                                    <EventTrigger RoutedEvent="Ellipse.Loaded">
                                        <BeginStoryboard>
                                            <Storyboard SpeedRatio="3" RepeatBehavior="Forever" BeginTime="{Binding Converter={x:Static wpfLoaders:MultiplyIntToSecConverter.Instance}, ConverterParameter=0.3}">
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:9" Value="1"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:10" Value="0"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.RenderTransform).(TranslateTransform.Y)">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-40"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
                                                    <LinearDoubleKeyFrame KeyTime="0:0:9" Value="0"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:10" Value="40"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)">
                                                    <LinearColorKeyFrame KeyTime="0:0:0" Value="#F7EA5A"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:5.5" Value="#F7EA5A"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:6.0" Value="#02A9CB"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:10.0" Value="#02A9CB"/>
                                                </ColorAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </Ellipse.Triggers>
                            </Ellipse>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Viewbox>
        </HeaderedContentControl>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="Dots horizontal">
            <Viewbox Stretch="Uniform" Width="125" Height="125" RenderTransformOrigin="0.5,0.5">
                <ItemsControl>
                    <ItemsControl.ItemsSource>
                        <wpfLoaders:ItemsGenerator Items="10" />
                    </ItemsControl.ItemsSource>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Width="10" Height="10" Fill="LightGray" Margin="3">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform/>
                                </Rectangle.RenderTransform>
                                <Rectangle.Triggers>
                                    <EventTrigger RoutedEvent="Rectangle.Loaded">
                                        <BeginStoryboard>
                                            <Storyboard RepeatBehavior="Forever" BeginTime="{Binding Converter={x:Static wpfLoaders:MultiplyIntToSecConverter.Instance}, ConverterParameter=0.3}">
                                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)">
                                                    <LinearColorKeyFrame KeyTime="0:0:0" Value="LightGray"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:0.15" Value="#02A9CB"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:0.3" Value="LightGray"/>
                                                    <LinearColorKeyFrame KeyTime="0:0:3" Value="LightGray"/>
                                                </ColorAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </Rectangle.Triggers>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <Viewbox.RenderTransform>
                    <ScaleTransform CenterX="0.5"/>
                </Viewbox.RenderTransform>
                <Viewbox.Triggers>
                    <EventTrigger RoutedEvent="Viewbox.Loaded">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation From="0" To="1" Storyboard.TargetProperty="Opacity" Duration="0:0:0.5"/>
                                <DoubleAnimation From="0" To="1" Storyboard.TargetProperty="(Viewbox.RenderTransform).(ScaleTransform.ScaleX)" Duration="0:0:0.5"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Viewbox.Triggers>
            </Viewbox>
        </HeaderedContentControl>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="MultipleRings">
            <Viewbox Stretch="Fill">
                <wpfLoaders:MultipleRings />
            </Viewbox>
        </HeaderedContentControl>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="Piechart">
            <Viewbox Stretch="UniformToFill" Width="125" Height="125" RenderTransformOrigin="0.5,0.5">
                <Grid>
                    <Ellipse Width="100" Height="100">
                        <Ellipse.Fill>
                            <LinearGradientBrush>
                                <GradientStop Color="#F7EA5A" Offset="0"/>
                                <GradientStop Color="#F7EA5A" Offset="0.5"/>
                                <GradientStop Color="#C4BA47" Offset="2"/>
                            </LinearGradientBrush>
                        </Ellipse.Fill>
                        <Ellipse.Effect>
                            <DropShadowEffect ShadowDepth="0" BlurRadius="3"/>
                        </Ellipse.Effect>
                    </Ellipse>
                    <wpfLoaders:CircleSegment x:Name="Segment" StartDegree="0" EndDegree="0" Radius="50">
                        <wpfLoaders:CircleSegment.Fill>
                            <LinearGradientBrush>
                                <GradientStop Color="#02A9CB" Offset="0"/>
                                <GradientStop Color="#02A9CB" Offset="0.5"/>
                                <GradientStop Color="#02849F" Offset="2"/>
                            </LinearGradientBrush>
                        </wpfLoaders:CircleSegment.Fill>
                        <wpfLoaders:CircleSegment.Effect>
                            <DropShadowEffect ShadowDepth="0" BlurRadius="3"/>
                        </wpfLoaders:CircleSegment.Effect>
                        <wpfLoaders:CircleSegment.Triggers>
                            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                <BeginStoryboard>
                                    <Storyboard RepeatBehavior="Forever" Duration="0:0:2">
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(wpfLoaders:CircleSegment.EndDegree)">
                                            <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/>
                                            <LinearDoubleKeyFrame Value="360" KeyTime="0:0:1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(wpfLoaders:CircleSegment.StartDegree)">
                                            <LinearDoubleKeyFrame Value="0" KeyTime="0:0:1"/>
                                            <LinearDoubleKeyFrame Value="360" KeyTime="0:0:2"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </wpfLoaders:CircleSegment.Triggers>
                    </wpfLoaders:CircleSegment>
                </Grid>
            </Viewbox>
        </HeaderedContentControl>
        <HeaderedContentControl Style="{StaticResource LoaderDisplay}" Header="Stacking">
            <Viewbox Width="125" Height="125" Stretch="UniformToFill">
                <ItemsControl Margin="15">
                    <ItemsControl.ItemsSource>
                        <x:Array Type="sys:Int16">
                            <sys:Int16>2</sys:Int16>
                            <sys:Int16>3</sys:Int16>
                            <sys:Int16>0</sys:Int16>
                            <sys:Int16>1</sys:Int16>
                        </x:Array>
                    </ItemsControl.ItemsSource>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid Rows="2" Columns="2"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Width="40" Height="40" Fill="#02A9CB" Opacity="0" RenderTransformOrigin="0.5,0.5">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform Y="-20" />
                                </Rectangle.RenderTransform>
                                <Rectangle.Triggers>
                                    <EventTrigger RoutedEvent="Rectangle.Loaded">
                                        <BeginStoryboard>
                                            <Storyboard Duration="0:0:3.2" RepeatBehavior="Forever">
                                                <DoubleAnimation To="1" Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" BeginTime="{Binding Converter={x:Static wpfLoaders:MultiplyIntToSecConverter.Instance}, ConverterParameter=0.5}"/>
                                                <DoubleAnimation To="0" Storyboard.TargetProperty="Opacity" BeginTime="0:0:2" Duration="0:0:0.8" />
                                                <DoubleAnimation To="0" Storyboard.TargetProperty="(Rectangle.RenderTransform).(TranslateTransform.Y)" BeginTime="{Binding Converter={x:Static wpfLoaders:MultiplyIntToSecConverter.Instance}, ConverterParameter=0.5}" Duration="0:0:0.5"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </Rectangle.Triggers>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Viewbox>
        </HeaderedContentControl>
    </WrapPanel>
</Window>
